package ama.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ama.dao.DAO;
import ama.dao.ProduitDAO;
import ama.model.Panier;
import ama.model.Produit;

/**
 * Servlet implementation class ServletPanier
 */
@WebServlet("/ServletPanier")
public class ServletPanier extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletPanier() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		DAO<Produit> daoProd = new ProduitDAO();
		Panier panierUser = (Panier)request.getSession().getAttribute("Panier"); ;
		request.getParameter("listeProduit");
		
		if(request.getParameter("ArticleIDPanier")!=(null)){
			Produit p1 = daoProd.find(Integer.parseInt(request.getParameter("ArticleIDPanier")));
			panierUser.addArticlePanier(p1);
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.getParameterNames();
		
	}

}
